﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using MultipleDB.Entitys;
using MultipleDB.IRepository.Mes198;
using MultipleDB.IRepository.UnitOfWork;
using MultipleDB.IServices;
using MultipleDB.IServices.AGV198;
using MultipleDB.IServices.Mes198;
using PineLake.Drmwe.Lib.ResultMsg;

namespace MultipleDB.Services.Mes198
{
    public class SysUser_Services : BaseServices<SysUser>, ISysUser_Services
    {
        private readonly ISysUser_Repository _DAL;
        private readonly IAGVStation_Services _AGVStationServices;
        private readonly IUnitOfWork _UnitOfWork;
        private readonly IMapper _Mapper;
        private ActionResultMsg ActionResult = new();
        public SysUser_Services(IUnitOfWork IUnitOfWork, IMapper Mapper, ISysUser_Repository IDal, IAGVStation_Services aGVStation_Services)
        {
            _UnitOfWork = IUnitOfWork;
            _Mapper = Mapper;
            _DAL = IDal;
            BaseDal = IDal;
            _AGVStationServices = aGVStation_Services;
        }

        public async Task<bool> DelMultipleDBData(long SysUserId, int AGVStationId)
        {
             _UnitOfWork.BeginTran();
            _ = await _DAL.DeleteByIdAsync(SysUserId);
            var Bol = await _AGVStationServices.DeleteByIdAsync(AGVStationId);
             _UnitOfWork.RollbackTran();
            return Bol;
        }
    }
}
